/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Negocio;

/**
 *
 * @author sistemas
 */
public class VectorEntero {
    private int n;

    public int getN() {
        return n;
    }

    public void setN(int n) {
        this.n = n;
    }
    static final int Max=1000;
    private Negocio.Entero[] v=new Entero[Max];
    
    public boolean Lleno()
    {
        return n == Max;
    }
    public boolean Insertar(Negocio.Entero ele){
        if(!this.Lleno())
        {            
            v[n] = ele;
            n++;
            return true;
        }
        else
        {
            return false;
        }
    }
    public boolean Insertar(int ele){
        if(!this.Lleno())
        {
            Entero Obj1 = new Entero();
            Obj1.setNum(ele);
            v[n] = Obj1;
            n++;
            return true;
        }
        else
        {
            return false;
        }
    }
    public Entero LeerVector(int Posicion){
        return v[Posicion];
    }
    private void Intercambiar(Entero a, Entero b)
    {
        Entero aux = new Entero();
        aux.setNum(a.getNum());
        a.setNum(b.getNum());
        b.setNum(aux.getNum());
    }
    public void Ordenar(){
        for(int i = 0; i <= n-2; i++)
        {
            for(int j = i+1; j <= n-1; j++)
            {
                if(v[j].getNum() < v[i].getNum())
                {
                    this.Intercambiar(v[i],v[j]);
                }
            }
        }
    }
    public boolean Existe(int ele)
    {
        for(int i=0;i<=n-1;i++){
            if(v[i].getNum()==ele){
                return true;
            }
        }
        return false;
    }
    
}
